/******************************************************************************
* This file is part of is32p218 platform,
* Copyright (c) 2009 HangZhou InfoStrong CO.,LTD. All rights reserved.
* This software may only be used under the terms of a valid, current,
* end user license from InfoStrong.
* Nothing else gives you the right to use this software.   
*
* Name:   drv_pwr.c
* Desc:   Power Module Driver C File
* Author: Jerry
* Date:   2009-9-16
* Note:   
* History:
*
******************************************************************************/
#include <string.h>
#include "option.h"
#include "xn5106x.h"
#include "drv_sys.h"
#include "drv_pwr.h"

volatile U32 g_drv_pwr_flg = 0;

/*
* Function Name:
*   drv_pwr_flg_set
* Description:
*   System Power Flags set
* Parameters:
*   U32 set_flgs: 1 is validate
* Returns: 
*   None 
* Author				Date 
*  Jerry				2009-9-16   
* Note:
*    
*/
void drv_pwr_flg_set( U32 set_flgs )
{
	/* Disable Interrupt */
	// $$$$$$$$$$$$$$$$$$$$$$
	g_drv_pwr_flg |= set_flgs;
	/* Enable Interrupt */
}
/*
* Function Name:
*   drv_pwr_flg_clr
* Description:
*   System Power Flags clear
* Parameters:
*   U32 clr_flgs: 1 is validate
* Returns: 
*   None 
* Author				Date 
*  Jerry				2009-9-16   
* Note:
*    
*/
void drv_pwr_flg_clr( U32 clr_flgs )
{
	/* Disable Interrupt */
	// $$$$$$$$$$$$$$$$$$$$$$
	g_drv_pwr_flg &= (~clr_flgs);
	/* Enable Interrupt */
}

/*
* Function Name:
*   drv_pwr_flg_get
* Description:
*   Get System Power Flags
* Parameters:
* Returns:
*  	U32: 0--System will enter IDLE mode
* 	     other--System can't enter IDLE mode
* Author				Date 
*  Jerry				2009-9-16   
* Note:
*    
*/
U32 drv_pwr_flg_get( void )
{
	U32 tmp_flg;
	/* Disable Interrupt */
	// $$$$$$$$$$$$$$$$$$$$$$
	tmp_flg = g_drv_pwr_flg;
	/* Enable Interrupt */
	return tmp_flg;
}

/*
* Function Name:
*   drv_pwr_idle_req
* Description:
*   System Idle mode requet
* Parameters:
* Returns:
* Author				Date 
*  Jerry				2009-9-16   
* Note:
*  	 In this mode, CPU Core will stop,
* 	 but external OSC is still running
*/
void drv_pwr_idle_req( void )
{
	/* Disable Interrupt */
#if 0
	if (0==g_drv_pwr_flg)
	{
		rSYSCON |= BIT1;  //enter IDLE mode.
		__asm
		{
			nop;
			nop;
			nop;
			nop;
		}
		//Wait any interrupts. MCU is in IDLE mode now.
	}
#endif	
	/* Enable Interrupt */
}

/*
* Function Name:
*   drv_pwr_stop_req
* Description:
*   System STOP mode request
* Parameters: 
*   None 
* Returns: 
*   None 
* Author				Date 
*  Jerry				2009-9-16   
* Note:
*    
*/
void drv_pwr_stop_req( void )
{
}

